<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Rails::Generator::Commands::Destroy</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Rails::Generator::Commands::Destroy</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/rails/railties/lib/rails_generator/commands_rb.html">
                vendor/rails/railties/lib/rails_generator/commands.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="RewindBase.html">
                RewindBase
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Undo the actions performed by a generator. Rewind the action manifest and
attempt to completely erase the results of each action.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001494">complex_template</a>&nbsp;&nbsp;
      <a href="#M001493">directory</a>&nbsp;&nbsp;
      <a href="#M001491">file</a>&nbsp;&nbsp;
      <a href="#M001495">migration_template</a>&nbsp;&nbsp;
      <a href="#M001496">route_resources</a>&nbsp;&nbsp;
      <a href="#M001492">template</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001494" class="method-detail">
        <a name="M001494"></a>

        <div class="method-heading">
          <a href="#M001494" class="method-signature">
          <span class="method-name">complex_template</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001494-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001494-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/commands.rb, line 484</span>
484:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">complex_template</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
485:           <span class="ruby-comment cmt"># nothing should be done here</span>
486:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001493" class="method-detail">
        <a name="M001493"></a>

        <div class="method-heading">
          <a href="#M001493" class="method-signature">
          <span class="method-name">directory</span><span class="method-args">(relative_path)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Remove each <a href="Destroy.html#M001493">directory</a> in the given path
from right to left. Remove each subdirectory if it exists and is a <a
href="Destroy.html#M001493">directory</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001493-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001493-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/commands.rb, line 450</span>
450:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">directory</span>(<span class="ruby-identifier">relative_path</span>)
451:           <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">relative_path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>)
452:           <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">empty?</span>
453:             <span class="ruby-identifier">partial</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">parts</span>)
454:             <span class="ruby-identifier">path</span> = <span class="ruby-identifier">destination_path</span>(<span class="ruby-identifier">partial</span>)
455:             <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">path</span>)
456:               <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Dir</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value str">'*'</span>)].<span class="ruby-identifier">empty?</span>
457:                 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">rmdir</span> <span class="ruby-identifier">partial</span>
458:                 <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:pretend</span>]
459:                   <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:svn</span>]
460:                     <span class="ruby-comment cmt"># If the directory has been marked to be added</span>
461:                     <span class="ruby-comment cmt"># but has not yet been checked in, revert and delete</span>
462:                     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:svn</span>][<span class="ruby-identifier">relative_path</span>]
463:                       <span class="ruby-identifier">system</span>(<span class="ruby-node">&quot;svn revert #{path}&quot;</span>)
464:                       <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">path</span>)
465:                     <span class="ruby-keyword kw">else</span>
466:                     <span class="ruby-comment cmt"># If the directory is not in the status list, it</span>
467:                     <span class="ruby-comment cmt"># has no modifications so we can simply remove it</span>
468:                       <span class="ruby-identifier">system</span>(<span class="ruby-node">&quot;svn rm #{path}&quot;</span>)
469:                     <span class="ruby-keyword kw">end</span>
470:                   <span class="ruby-keyword kw">else</span>
471:                     <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">path</span>)
472:                   <span class="ruby-keyword kw">end</span>
473:                 <span class="ruby-keyword kw">end</span>
474:               <span class="ruby-keyword kw">else</span>
475:                 <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">notempty</span> <span class="ruby-identifier">partial</span>
476:               <span class="ruby-keyword kw">end</span>
477:             <span class="ruby-keyword kw">else</span>
478:               <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">missing</span> <span class="ruby-identifier">partial</span>
479:             <span class="ruby-keyword kw">end</span>
480:             <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">pop</span>
481:           <span class="ruby-keyword kw">end</span>
482:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001491" class="method-detail">
        <a name="M001491"></a>

        <div class="method-heading">
          <a href="#M001491" class="method-signature">
          <span class="method-name">file</span><span class="method-args">(relative_source, relative_destination, file_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Remove a <a href="Destroy.html#M001491">file</a> if it exists and is a <a
href="Destroy.html#M001491">file</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001491-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001491-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/commands.rb, line 418</span>
418:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file</span>(<span class="ruby-identifier">relative_source</span>, <span class="ruby-identifier">relative_destination</span>, <span class="ruby-identifier">file_options</span> = {})
419:           <span class="ruby-identifier">destination</span> = <span class="ruby-identifier">destination_path</span>(<span class="ruby-identifier">relative_destination</span>)
420:           <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">destination</span>)
421:             <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">rm</span> <span class="ruby-identifier">relative_destination</span>
422:             <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:pretend</span>]
423:               <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:svn</span>]
424:                 <span class="ruby-comment cmt"># If the file has been marked to be added</span>
425:                 <span class="ruby-comment cmt"># but has not yet been checked in, revert and delete</span>
426:                 <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:svn</span>][<span class="ruby-identifier">relative_destination</span>]
427:                   <span class="ruby-identifier">system</span>(<span class="ruby-node">&quot;svn revert #{destination}&quot;</span>)
428:                   <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>(<span class="ruby-identifier">destination</span>)
429:                 <span class="ruby-keyword kw">else</span>
430:                 <span class="ruby-comment cmt"># If the directory is not in the status list, it</span>
431:                 <span class="ruby-comment cmt"># has no modifications so we can simply remove it</span>
432:                   <span class="ruby-identifier">system</span>(<span class="ruby-node">&quot;svn rm #{destination}&quot;</span>)
433:                 <span class="ruby-keyword kw">end</span>  
434:               <span class="ruby-keyword kw">else</span>
435:                 <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>(<span class="ruby-identifier">destination</span>)
436:               <span class="ruby-keyword kw">end</span>
437:             <span class="ruby-keyword kw">end</span>
438:           <span class="ruby-keyword kw">else</span>
439:             <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">missing</span> <span class="ruby-identifier">relative_destination</span>
440:             <span class="ruby-keyword kw">return</span>
441:           <span class="ruby-keyword kw">end</span>
442:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001495" class="method-detail">
        <a name="M001495"></a>

        <div class="method-heading">
          <a href="#M001495" class="method-signature">
          <span class="method-name">migration_template</span><span class="method-args">(relative_source, relative_destination, template_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
When deleting a migration, it knows to delete every <a
href="Destroy.html#M001491">file</a> named &quot;[0-9]*_#{file_name}&quot;.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001495-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001495-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/commands.rb, line 489</span>
489:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">migration_template</span>(<span class="ruby-identifier">relative_source</span>, <span class="ruby-identifier">relative_destination</span>, <span class="ruby-identifier">template_options</span> = {})
490:           <span class="ruby-identifier">migration_directory</span> <span class="ruby-identifier">relative_destination</span>
491: 
492:           <span class="ruby-identifier">migration_file_name</span> = <span class="ruby-identifier">template_options</span>[<span class="ruby-identifier">:migration_file_name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">file_name</span>
493:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">migration_exists?</span>(<span class="ruby-identifier">migration_file_name</span>)
494:             <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;There is no migration named #{migration_file_name}&quot;</span>
495:             <span class="ruby-keyword kw">return</span>
496:           <span class="ruby-keyword kw">end</span>
497: 
498: 
499:           <span class="ruby-identifier">existing_migrations</span>(<span class="ruby-identifier">migration_file_name</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file_path</span><span class="ruby-operator">|</span>
500:             <span class="ruby-identifier">file</span>(<span class="ruby-identifier">relative_source</span>, <span class="ruby-identifier">file_path</span>, <span class="ruby-identifier">template_options</span>)
501:           <span class="ruby-keyword kw">end</span>
502:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001496" class="method-detail">
        <a name="M001496"></a>

        <div class="method-heading">
          <a href="#M001496" class="method-signature">
          <span class="method-name">route_resources</span><span class="method-args">(*resources)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001496-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001496-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/commands.rb, line 504</span>
504:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_resources</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">resources</span>)
505:           <span class="ruby-identifier">resource_list</span> = <span class="ruby-identifier">resources</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">to_sym</span>.<span class="ruby-identifier">inspect</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">', '</span>)
506:           <span class="ruby-identifier">look_for</span> = <span class="ruby-node">&quot;\n  map.resources #{resource_list}\n&quot;</span>
507:           <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">route</span> <span class="ruby-node">&quot;map.resources #{resource_list}&quot;</span>
508:           <span class="ruby-identifier">gsub_file</span> <span class="ruby-value str">'config/routes.rb'</span>, <span class="ruby-node">/(#{look_for})/</span><span class="ruby-identifier">mi</span>, <span class="ruby-value str">''</span>
509:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001492" class="method-detail">
        <a name="M001492"></a>

        <div class="method-heading">
          <span class="method-name">template</span><span class="method-args">(relative_source, relative_destination, file_options = {})</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Destroy.html#M001491">file</a>
</p>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>